package com.newly.api.business.feign;

import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import com.newly.common.base.entity.business.Dto.CompanyDto;
import com.newly.common.base.entity.business.Po.Company;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @anthor sbq
 * @date 2021/10/29 9:57
 */
@Api(tags = "企业信息管理api")
@FeignClient(path = ServerUriConstant.NEWLY_BUSINESS_COMPANY, name = ServerUriConstant.NEWLY_BUSINESS_SERVICE_NAME)
public interface CompanyClient {

    @ApiOperation("添加检测记录测试数据")
    @PostMapping("/saveCheckRecord")
    R saveCheckRecord();

    @ApiOperation("导出企业信息表")
    @GetMapping("/export")
    void export(@RequestParam(value = "name", required = false) String name,
                @RequestParam(value = "contactsName", required = false) String contactsName,
                @RequestParam(value = "offset", defaultValue = "7") Integer offset,
                HttpServletResponse response);

    @ApiOperation("分页查询企业列表")
    @GetMapping("/getPage")
    R getPage(CompanyDto companyDto);

    @ApiOperation("根据id查询企业基础信息和违法历史记录")
    @GetMapping("/getDetailsById")
    R getDetailsById(@RequestParam(value = "id", required = false) Long id,
                     @RequestParam(value = "offset", required = false) Integer offset);

    /**
     * 编辑
     *
     * @param company
     * @return
     */
    @ApiOperation("编辑企业信息")
    @PostMapping("/edit")
    R edit(@Valid @RequestBody Company company);


    /**
     * 保存
     *
     * @param company
     * @return
     */
    @ApiOperation("保存一条记录")
    @PostMapping("/save")
    R save(@Valid @RequestBody Company company);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @ApiOperation("批量删除")
    @PostMapping("/delete")
    R delete(@RequestBody Long[] ids);

    /**
     * 获取所有企业名称
     *
     * @param
     * @return
     */
    @ApiOperation("获取所有企业名称")
    @GetMapping("/getCompanyNames")
    R getCompanyNames();

    /**
     * 企业名称是否重复
     *
     * @param companyName
     * @return
     */
    @ApiOperation("企业名称是否重复")
    @GetMapping("/repeat")
    R repeat(@RequestParam(value = "companyName", required = false) String companyName);

    @ApiOperation("通过id查询企业信息")
    @GetMapping("/queryByIds")
    R queryByIdsInAuth(@RequestParam("companyIds") List<String> companyIds);
}
